<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
<%--    Ctrl+/--%>
<%--     <title>JSP - Hello World</title>--%>
    <%! ResultSet rs;%>
    <%
        String dbName = "goods";//数据库名称
        String userName = "root";//数据库用户
        String userPasswd = "1234";//数据库密码
        String url = "jdbc:mysql://localhost:3306/" + dbName + "?user=" + userName + "&password=" + userPasswd+"&useUnicode=true&characterEncoding=utf-8";
        Class.forName("com.mysql.cj.jdbc.Driver");//加载链接数据的驱动
        Connection conn = DriverManager.getConnection(url);//链接数据库
        Statement statement = conn.createStatement();
        String sql = "select * from goods";//要执行的数据库语句
        rs = statement.executeQuery(sql);//获取查询结果
    %>
</head>
<body style="background: #efefef">
<div style="display: flex;flex-direction: row;width: 1042px;flex-wrap: wrap">
<%
    while(rs.next()) {//循环显示在数据库中查出来的数据
%>

<jsp:include page="include.jsp">
    <jsp:param name="name" value='<%=rs.getString("name")%>'/>
    <jsp:param name="price" value='<%=rs.getString("price")%>'/>
    <jsp:param name="des" value='<%=rs.getString("des")%>'/>
    <jsp:param name="img" value='<%=rs.getString("img")%>'/>
</jsp:include>


<%
    }
%>
</div>

</body>
</html>